-- @owner: opentestcase018
-- @date: 2022/01/19
-- @testpoint: 触发器中不支持包含commit/rollback 部分测试点合理报错

--step1:建表;expect:成功
drop table if exists t_ustore_trigger_src_0018;
drop table if exists t_ustore_trigger_des_0018;
create table t_ustore_trigger_src_0018(id1 int, id2 int, id3 int) with (storage_type=ustore);
create table t_ustore_trigger_des_0018(id1 int, id2 int, id3 int) with (storage_type=ustore);

--step2:触发器中不支持包含commit/rollback;expect:成功
create or replace function fun_insert_ustore_0018() returns trigger as
$$
declare
begin
    insert into t_ustore_trigger_des_0018 values(new.id1, new.id2, new.id3);
    rollback;
    insert into t_ustore_trigger_des_0018 values(new.id3, new.id1, new.id2);
    commit;
    return new;
end;
$$ language plpgsql;
/

create trigger tri_ustore_0018 before insert on t_ustore_trigger_src_0018
for each row
    execute procedure fun_insert_ustore_0018();
/
insert into t_ustore_trigger_src_0018 values(1,2,3);

select * from t_ustore_trigger_des_0018;

--step3:环境清理;expect:成功
drop trigger tri_ustore_0018 on t_ustore_trigger_src_0018;
drop table  t_ustore_trigger_src_0018;
drop table  t_ustore_trigger_des_0018;
drop procedure fun_insert_ustore_0018();